package com.axjy.controller;

import com.axjy.pojo.Menu;
import com.axjy.pojo.User;
import com.axjy.service.PermissionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class IndexController {

    @Resource
    private PermissionService permissionService;

    @GetMapping("/index")
    public String index(HttpSession session,Model model){
        User loginUser= (User) session.getAttribute("loginUser");
        if(loginUser!=null){
            Map<Menu,List<Menu>> map=permissionService.createNavigator(loginUser);
            model.addAttribute("map",map);
        }
        return "index";
    }


}
